<template>
  <el-form :model="fromData" :rules="fromData_rules" ref="fromDataRef" label-width="100px">
    <!-- <el-form-item label="名称" prop="name">
      <el-input :readonly="_readonly" v-model="fromData.name"></el-input>
    </el-form-item> -->
    <el-form-item  v-if="!set" label="断面前缀" prop="prefix">
      <el-input :readonly="_readonly" v-model="fromData.prefix"></el-input>
    </el-form-item>
    <el-form-item  v-if="!set" label="开始里程" prop="startMileage">
      <el-input :readonly="_readonly" v-model="fromData.startMileage"></el-input>
    </el-form-item>
    <el-form-item v-if="!set" label="添加数量" prop="num">
      <el-input type="number" min="1" max="99" :readonly="_readonly" v-model="fromData.num" @change="(fromData.num>1&&fromData.sectionInterval==0)?(fromData.sectionInterval=.1):null"></el-input>
    </el-form-item>
    <el-form-item v-if="!set" label="断面间隔" prop="sectionInterval">
      <el-input type="number" :min="(fromData.num>1)?'.1':'0'" :readonly="_readonly" v-model="fromData.sectionInterval"></el-input>
    </el-form-item>
    <!-- <el-form-item label="结束里程" prop="endMileage">
      <el-input :readonly="_readonly" v-model="fromData.endMileage"></el-input>
    </el-form-item> -->
    <el-form-item label="负责小组" prop="groupName">
      <iSelectedGroup :defaultSelect="fromData.groupId" @selectChange="groupChangeFun">
        <el-input v-if="selectedName" :readonly="_readonly" v-model="selectedName"></el-input>
        <el-input v-else :readonly="_readonly" v-model="fromData.groupName"></el-input>
      </iSelectedGroup>
    </el-form-item>
    <!-- <el-form-item label="施工工况" prop="constructionState">
      <el-input :readonly="_readonly" v-model="fromData.constructionState"></el-input>
    </el-form-item>
    <el-form-item label="埋设位置" prop="embeddingLocation">
      <el-input :readonly="_readonly" v-model="fromData.embeddingLocation"></el-input>
    </el-form-item>
    <el-form-item label="依据标准" prop="standard">
      <el-input :readonly="_readonly" v-model="fromData.standard"></el-input>
    </el-form-item>
    <el-form-item label="环境条件" prop="surroundings">
      <el-input :readonly="_readonly" v-model="fromData.surroundings"></el-input>
    </el-form-item> -->
    <el-form-item label="备注" prop="remark">
      <el-input :readonly="_readonly" type="textarea" v-model="fromData.remark"></el-input>
    </el-form-item>
  </el-form>
</template>

<script>
export default {
  props: {
    fromData: {},
    _readonly: {
      type: Boolean,
      default: false
    },
    set: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      fromData_rules: {
        // name: [{ required: true, message: '请输入名称', trigger: 'change' }],
        prefix: [{ required: true, message: '请输入断面前缀', trigger: 'change' }],
        sectionInterval: [{ required: true, message: '请输入断面间隔', trigger: 'change' }],
        startMileage: [{ required: true, message: '请输入开始里程', trigger: 'change' }],
        endMileage: [{ required: true, message: '请输入结束里程', trigger: 'change' }],
        num: [{ required: true, message: '请输入添加数量', trigger: 'change' }]
      },
      selectedName: ''
    }
  },
  methods: {
    validate() {
      let res_bool = false
      this.$refs.fromDataRef.validate(bool => {
        res_bool = bool
      })
      return res_bool
    },
    resetFields() {
      this.$refs.fromDataRef.resetFields()
    },
    groupChangeFun(selected) {
      this.fromData.groupName = selected.name
      this.selectedName = selected.name
      this.fromData.groupId = selected.id
    }
  }
}
</script>

<style>
</style>